<!DOCTYPE html>
<html lang="en">
<head>
    <title>学生界面</title>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="static/css/font-awesome.css" rel="stylesheet" />
    <link href="static/css/style.css" rel="stylesheet" />
    <link href="static/css/lcy_css.css" rel="stylesheet" />
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <style>
        .fixed{
            position: fixed;
            left: 0;
            right: 0;
            margin: auto;
            top: 20%;
}
    </style>
</head>
    <div class="container">
        <div class="row">
            <div class="row">
                <div class="col-sm-10 col-md-10 col-lg-10">
                    <h1>
                        学生选课和成绩管理系统
                    </h1>
                </div>
                <div class="col-sm-2 col-md-2 col-lg-2">
                    <p name="adm_username" id="adm_username">{{adm}}</p>
                    <button type="button" class="btn btn-link" data-toggle="modal" data-target="#update_password">
                        修改密码
                    </button>
                    <button type="button" class="btn btn-link" onclick="log_out()">
                        退出登录
                    </button>
                </div>
            </div>
            <div class="modal fade" id="update_password" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                            <h4 class="modal-title" id="myModalLabel">修改密码</h4>
                        </div>
                        <div class="modal-body">
                            <form role="form" method="post" id="lc_up_pass">
                                <div class="form-group">
                                    <label for="password1">密码</label>
                                    <input type="password" class="form-control" id="password1" name="password1" placeholder="">
                                </div>
                                <div class="form-group">
                                    <label for="password2">确认密码</label>
                                    <input type="password" class="form-control" id="password2" name="password2" placeholder="">
                                </div>
                                <div>
                                    <button type="button" class="btn btn-default" onclick="up_ps()">
                                        确认
                                    </button>
                                    <button type="button" class="btn btn-default" data-dismiss="modal">
                                        关闭
                                    </button>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer">
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
        </div>
        <div class="row panel panel-success">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#course">选课与退课</a></li>
                <li><a data-toggle="tab" href="#grade">成绩信息</a></li>
                <li><a data-toggle="tab" href="#detail">个人信息</a></li>
            </ul>
        </div>
        <div class="row tab-content">
            <div id="course" class="tab-pane fade in active">
<!--                选课表-->
                <div class="col-sm-5 col-md-5 col-lg-5 lcytable">
                    <h3>已选课</h3>
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>课程号</th>
                                <th>课程名</th>
                                <th>课程类别</th>
                                <th>任课教师</th>
                                <th>退课</th>
                            </tr>
                        </thead>
                        <tbody id="cho_body">
                            {% for i in choices %}
                            <form method="post" action="/xch_del_co">
                            <tr id="cho" name="cho">
                                <td>
                                    <input type="hidden" id="cho_num" name="cho_num" value="{{i[0]}}">
                                    {{i[0]}}
                                </td>
                                <td>
<!--                                    <input type="hidden" id="cho_name" name="cho_name" value="{{i[1]}}">-->
                                    {{i[1]}}
                                </td>
                                <td>
<!--                                    <input type="hidden" id="cho_type" name="cho_type" value="{{i[2]}}">-->
                                    {{i[2]}}
                                </td>
                                <td>
<!--                                    <input type="hidden" id="cho_tea" name="cho_tea" value="{{i[3]}}">-->
                                    {{i[3]}}
                                </td>
                                <td>
<!--                                    <button type="button" class="btn btn-link" onclick="sc_course({{i[0]}})">-->
<!--                                        <span class="glyphicon glyphicon-remove" style="color: Red"></span>-->
<!--                                    </button>-->
                                    <input type="submit" value="退课" style="align-content: center;">
                                </td>
                            </tr>
                            </form>
                            {% endfor %}
                        </tbody>

                    </table>
                </div>
<!--                课程表-->
                <div class="col-sm-6 col-md-6 col-lg-6 lcytable">
                    <h3>全部课程</h3>
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>选课</th>
                                <th>课程号</th>
                                <th>课程名</th>
                                <th>剩余量</th>
                                <th>课程类别</th>
                                <th>任课教师</th>
                            </tr>
                        </thead>
                        <tbody id="co">
                            {% for i in courses %}

                            <tr id="co{{i[0]}}">
                                <form method="post" action="/xch_co_co">
                                <td>
<!--                                    <button type="button" class="btn btn-link" onclick="xk_course({{i[0]}})">-->
<!--                                        <span class="glyphicon glyphicon-arrow-left" style="color: Green"></span>-->
<!--                                    </button>-->
                                    <input type="submit" value="选课" style="align-content: center;" onclick="xk_course()">
                                </td>
                                <td>
                                     <input type="hidden" id="co_num" name="co_num" value="{{i[0]}}">
                                    {{i[0]}}
                                </td>
                                <td id="co_name">
                                    {{i[1]}}
                                </td>
                                <td id="co_left">
                                    {{i[2]}}
                                </td>
                                <td id="co_type">
                                    {{i[3]}}
                                </td>
                                <td id="co_tea">
                                    {{i[4]}}
                                </td>
                                </form>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="grade" class="tab-pane fade" >
<!--                成绩表-->
                <div class="col-sm-5 col-md-5 col-lg-5 lcytable fixed" align="center">
                    <table class="table table-striped table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>课程号</th>
                                <th>课程名</th>
                                <th>课程类别</th>
                                <th>任课教师</th>
                                <th>成绩</th>
                            </tr>
                        </thead>
                        <tbody id="graade_body">
                            {% for i in grades %}
                            <tr id="g{{i[0]}}">
                                <td id="g_num{{i[0]}}">
                                    {{i[0]}}
                                </td>
                                <td id="g_name{{i[0]}}">
                                    {{i[1]}}
                                </td>
                                <td id="g_type{{i[0]}}">
                                    {{i[2]}}
                                </td>
                                <td id="g_tea{{i[0]}}">
                                    {{i[3]}}
                                </td>
                                <td id="g_g{{i[0]}}">
                                    {{i[4]}}
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="detail" class="tab-pane fade">
<!--                个人信息-->
                <form role="form"id="stu_detail" method="get">
                        <div>
                            <div class="form-group">
                            <label for="xh">学号:</label>
                            <input type="text" class="form-control" id="xh" name="xh" readonly="readonly" value="{{stu_num}}">
                        </div>
                            <div class="form-group">
                            <label for="xm">姓名:</label>
                            <input type="text" class="form-control" id="xm" name="xm" readonly="readonly" value="{{stu_name}}">
                        </div>
                            <div class="form-group">
                            <label for="xb">性别:</label>
                             <input type="text" class="form-control" name="xb" id="xb" readonly="readonly" value="{{stu_sex}}">
                        </div>
                            <div class="form-group">
                            <label for="sr">生日:</label>
                            <input type="text" class="form-control" name="sr" id="sr" readonly="readonly" value="{{stu_birth}}">
                        </div>
                            <div class="form-group">
                            <label for="bj">班级:</label>
                            <input type="text" class="form-control" name="bj" id="bj" readonly="readonly" value="{{stu_class}}">
                        </div>
                        </div>
                    </form>
            </div>
        </div>
    </div>
    <script src="https://code.jquery.com/jquery.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--    <script src="static/js/up_ps.js"></script>-->
<script type="text/javascript">
function up_ps(){
    var p1=document.getElementById("password1").value;
    var p2=document.getElementById("password2").value;
    var username=document.getElementById('adm_username').innerText;
    var form= new FormData(document.getElementById("lc_up_pass"));
    form.append('username',username)
    if(p1!=p2){
        alert("两次密码不相同。");
        return true;
    }
    $.ajax({
            url:"{{ url_for('lcy_up_pas') }}",
            type:"post",
            data:form,
            processData:false,
            contentType:false,
            success:function(dat){
                if(dat.flag){
                    alert("更新成功");
                }else{
                    alert("更新失败");
                }
            },
            error:function(e){
                    alert("error");
            }
        })
    return true;
}
function log_out(){
    $.ajax({
            url:"{{ url_for('lcy_log_out') }}",
            type:"post",
            data:null,
            processData:false,
            contentType:false,
            success:function(dat){
                if(dat.flag){
                    open(location, '_self').close();
                }else{
                    alert("退出失败");
                }
            },
            error:function(e){
                alert("error");
            }
        })
       return true;
}
function sc_course(stu_id,co_id) {
    // 这是干嘛的
    // var ls='#stu'+stu_id;//用id来选择


}
</script>
</body>
</html>
